<?php
class system_nav_page {
	private $_route = null;
	private $_label = null;
	private $_params = array();
	private $_query = array();
	private $_path = null;
	
	public function __construct($label = null) {
		if($label) {
			$this->setLabel($label);
		}
	}
	
	/**
	 * @return system_nav_page
	 */
	public static function create($label = null) {
		return new self($label);
	}
	
	/**
	 * @return system_nav_page
	 */
	public function setRoute($route) {		
		$this->_route = system_controller_front::getInstance()->getRouter()->getRoute($route);	
		return $this;
	}
	/**
	 * @return system_controller_router_route_default
	 */
	public function getRoute() {
		return $this->_route;
	}
	/**
	 * @return system_nav_page
	 */
	public function setParams(array $params) {
		$this->_params = $params;
		return $this;
	}
	public function getParams() {
		return $this->_params;
	}
	/**
	 * @return system_nav_page
	 */
	public function setQuery(array $query) {
		$this->_query = $query;
		return $this;
	}
	public function getQuery() {
		return $this->_query;
	}	
	/**
	 * @return system_nav_page
	 */
	public function setLabel($label) {
		$this->_label = $label;
		return $this;
	}
	public function getLabel() {
		return $this->_label;
	}
	
	public function path() {
		if(null === $this->_path) {
			$this->_path = $this->getRoute()->assemble($this->getParams());
		}
		return $this->_path;
	}
	
	public function href() {
		$link = $this->path();
		if($this->_query) {
			$link .= '?' . http_build_query($this->_query);
		}
		return $link;
	}

}



